package com.zang.blogz.controller;

import com.zang.blogz.annotation.OptLog;
import com.zang.blogz.constant.OptTypeConstant;
import com.zang.blogz.entity.Page;
import com.zang.blogz.model.input.ro.PageImageRo;
import com.zang.blogz.result.Result;
import com.zang.blogz.service.PageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 页面 前端控制器
 * </p>
 *
 * @author 朵橙i
 * @since 2022-06-17
 */
@RestController
@RequestMapping("/blogz/page")
@Api(tags ="页面信息模块")
public class PageController {

    @Autowired
    private PageService pageService;

    @GetMapping("/info")
    @ApiOperation(notes = "获取页面列表", value = "获取页面列表")
    public Result<List<Page>> getPageInfoList(){

       return Result.ok(pageService.getPageInfoList());
    }

    @DeleteMapping("/admin/deleteById")
    @OptLog(optType = OptTypeConstant.REMOVE)
    @ApiOperation(notes = "删除页面", value = "删除页面")
    public Result<String> deleteById(@RequestParam("id") Integer id){

        return pageService.deleteById(id);
    }

    @PostMapping("/uploadByPageId")
    @ApiOperation(notes = "修改页面图片", value = "修改页面图片")
    public Result<String> uploadByPageId(@RequestBody PageImageRo pageImageRo){

        return pageService.uploadByPageId(pageImageRo);
    }



    
}
